﻿<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>BalanceRemind</title>
    <script src="../../Scripts/jquery-1.9.1.min.js" type="text/javascript"></script>
    <script src="../../Scripts/layer.js" type="text/javascript"></script>
    <link href="../../Content/Themes/blue2/css.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        .BalanceNav1{ margin-left:20px; margin-top:20px;}
        #sendEmail,#sendMsg,#excel,#Exit{ margin-left:50px;}
        .BalanceNav2{  margin-top:30px; width:94%; margin-left:auto; margin-right:auto; overflow:scroll;}
        .BalanceTabel th,td{ word-break:keep-all; white-space:nowrap;  border:1px black solid ; padding:3px; }
        .BalanceTabel{ border-color:#1C1C1C; height: 100%; width:100%;overflow:scroll;text-align:center; border-collapse:collapse; border-spacing:0;}
        .pager{ margin-left:30%;  padding-top:20px; padding-bottom:10px;}
        input[ type="text"]{width:150px;border:none; border-bottom:solid 1px #ccc; height:18px; line-height:18px; font-size:12px;  padding:1px 2px 1px 2px;}
    </style>
</head>
 <body class="main">
   <div  class="AllWebTopDiv"> 
           <div class="path">
             <div class="nav">
               <a href="#">卡金提醒</a>
             </div>
        </div>
       <div class="content">
       <div class="BalanceNav1">
         低于金额： <input type="text" name="Number" id="Number"  class="Line"  value="200"/>
          <input  type="button" id="search" value="搜索" class="button2" onclick="search();" />
          <input  type="button" id="sendEmail" value="邮件群发" class="button2""/> 
          <input  type="button" id="excel" value="Excel导出" class="button2" onclick="daochu()"/>
          <input  type="button" id="Exit" value="关闭" class="button2" onclick="closeWindows();" />
       </div>
       <div class="BalanceNav2">
      <table id="ShowData" border="1"  class="BalanceTabel">

    </table>      
        <div class="pager">
       <input  type="button" onmouseover="this.style.fontWeight='bold'" onmouseout="this.style.color='black';this.style.fontWeight='normal'" onclick="newPage('首页')"style="cursor:pointer"  value="首页" class="button"/>
         <input type="button" value="上一页" onmouseover="this.style.fontWeight='bold'" onmouseout="this.style.color='black';this.style.fontWeight='normal'" onclick="newPage('上一页')"style="cursor:pointer" class="button"/>
         <input type="button" value="下一页" onmouseover="this.style.fontWeight='bold'" onmouseout="this.style.color='black';this.style.fontWeight='normal'" onclick="newPage('下一页')"style="cursor:pointer" class="button"/>
         <input type="button" value="末页" onmouseover="this.style.fontWeight='bold'" onmouseout="this.style.color='black';this.style.fontWeight='normal'" onclick="newPage('末页')"style="cursor:pointer" class="button"/>
      
       　共 <label id="maxPage">1</label> 页 第 <label id="CurrentPage">1</label> 页
       </div>
  
       </div>
    
    </div>
    </div>
 </body>
</html>
<script type="text/javascript">

     var pageNum=1;
     var pageSize=15;
     var balance = document.getElementById("Number").value;
   //搜索
    function search() {

        balance = document.getElementById("Number").value;
        var strReg="^\\d+$";
        var re=new RegExp(strReg);
        if (balance.match(re)!=null) {
               $.ajax({
            type:"POST",
            url:"<%:Url.Action("LoadData","BalanceRemind") %>",
            data:"pageSize="+pageSize+"&balance="+balance+"",
            cache:false,
            success:function(html)
            {
    
                $("#ShowData").html(html);
                newPage("首页");
            }
           })
               $.ajax({
            type:"POST",
            url:"<%:Url.Action("Data_Load_maxPage","BalanceRemind") %>",
            data:"pageSize="+pageSize+"&balance="+balance+"",
            cache:false,
            success:function(html)
            {
                $("#maxPage").html(html);
               
            }
        })
        }
        else {
            alert("金额应为正整数");
        }
    }
    


      $.ajax({
            type:"POST",
            url:"<%:Url.Action("LoadData","BalanceRemind") %>",
            data:"pageSize="+pageSize+"&balance="+balance+"",
            cache:false,
            success:function(html)
            {
    
                $("#ShowData").html(html);
                newPage("首页");
            }
           })
               $.ajax({
            type:"POST",
            url:"<%:Url.Action("Data_Load_maxPage","BalanceRemind") %>",
            data:"pageSize="+pageSize+"&balance="+balance+"",
            cache:false,
            success:function(html)
            {
                $("#maxPage").html(html);
               
            }
        })

        function newPage(sa)
        {
           var CurrentPage= $("#CurrentPage").html();
             var maxPage=$("#maxPage").html();
           
            maxPage=parseInt(maxPage);
            
            
            if(sa=="首页")
            {
                pageNum=1;
               document.getElementById("CurrentPage").innerHTML=pageNum;
            }
            if(sa=="下一页")
            {
                 if(CurrentPage>=maxPage)
                {
                     alert("已是最大页数");
                    return;
                }
                pageNum++;
                document.getElementById("CurrentPage").innerHTML=pageNum;
               
            }
            if(sa=="上一页")
            {
                 if(CurrentPage==1)
            {
                alert("已是最小页数");
                return;
            } 
                pageNum--;
                document.getElementById("CurrentPage").innerHTML=pageNum;
            }
            if(sa=="末页")
            {
                pageNum=maxPage;
                 document.getElementById("CurrentPage").innerHTML=pageNum;
            }
              $.ajax({
                type:"POST",
                url:"<%:Url.Action("newPage","BalanceRemind") %>",
                data:"pageNum="+pageNum+"&pageSize="+pageSize+"&balance="+balance+"",
                cache:false,
                success:function(html)
                {
                $("#ShowData").html(html); 
                }
            })
        }

          //导出
      function daochu(){
       balance = document.getElementById("Number").value;
        var strReg="^\\d+$";
        var re=new RegExp(strReg);
        if (balance.match(re)!=null) {
         window.open('/BalanceRemind/BalanceToExcel?balance='+balance);
            }

       }  //关闭窗口
       function closeWindows()
    {
     window.location.href = "/Loading/Index/?src=/Desktop/Index/";
    }

</script>
